home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / c01lab1.zip / SIMLATRS / BUOY.BDY < prev    next >
Text File  |  1992-11-11  |  7KB  |  179 lines

  1. -- ********************************************
  2. -- *                                          *
  3. -- *  Buoy_Sensor_Interface                   *  BODY
  4. -- *                                          *
  5. -- ********************************************
  6. package body Buoy_Sensor_Interface is
  7.  
  8.   My_Position : constant array (BUOY_ID) of LOCATION :=
  9.       ((Latitude  => (NORTH, 47.0),
  10.         Longitude => (EAST,  25.0)),
  11.        (Latitude  => (NORTH, 35.2),
  12.         Longitude => (EAST,  10.1)),
  13.        (Latitude  => (NORTH, 10.5),
  14.         Longitude => (EAST,  80.0)),
  15.        (Latitude  => (SOUTH, 30.0),
  16.         Longitude => (EAST,   5.0)),
  17.        (Latitude  => (SOUTH, 25.2),
  18.         Longitude => (WEST,  10.0)),
  19.        (Latitude  => (SOUTH, 70.0),
  20.         Longitude => (EAST,  10.0)),
  21.        (Latitude  => (SOUTH, 70.0),
  22.         Longitude => (EAST,  20.0)),
  23.        (Latitude  => (SOUTH, 70.0),
  24.         Longitude => (EAST,  30.0)),
  25.        (Latitude  => (SOUTH, 70.0),
  26.         Longitude => (EAST,  40.0)),
  27.        (Latitude  => (SOUTH, 70.0),
  28.         Longitude => (EAST,  50.0)),
  29.        (Latitude  => (SOUTH, 60.0),
  30.         Longitude => (EAST,  60.0)),
  31.        (Latitude  => (NORTH, 55.2),
  32.         Longitude => (WEST,  70.5)),
  33.        (Latitude  => (NORTH, 67.2),
  34.         Longitude => (EAST,  22.2)),
  35.        (Latitude  => (NORTH, 34.0),
  36.         Longitude => (EAST,  89.0)),
  37.        (Latitude  => (SOUTH, 76.2),
  38.         Longitude => (EAST,  55.0)),
  39.        (Latitude  => (NORTH, 12.0),
  40.         Longitude => (EAST,  12.0)),
  41.        (Latitude  => (SOUTH, 12.0),
  42.         Longitude => (EAST,  12.0)),
  43.        (Latitude  => (NORTH, 12.0),
  44.         Longitude => (WEST,  12.0)),
  45.        (Latitude  => (SOUTH, 12.0),
  46.         Longitude => (WEST,  12.0)),
  47.        (Latitude  => (NORTH,  1.0),
  48.         Longitude => (EAST,  80.0)));
  49.  
  50.   type BUOY_INDEX is array (BUOY_ID) of NATURAL;
  51.   Air_Temp_Index   : BUOY_INDEX :=
  52.       (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 5);
  53.   Water_Temp_Index : BUOY_INDEX :=
  54.       (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 5);
  55.   Wind_Speed_Index : BUOY_INDEX :=
  56.       (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 5);
  57.   Red_Index : BUOY_INDEX :=
  58.       (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 5);
  59.   Yellow_Index : BUOY_INDEX :=
  60.       (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 5);
  61.  
  62.   type TEMP_ARRAY is array (NATURAL range <>) of TEMPERATURE;
  63.   type SPEED_ARRAY is array (NATURAL range <>) of SPEED;
  64.   type FLAG_ARRAY is array (NATURAL range <>) of OFF_ON;
  65.  
  66.   Air_Temp : constant TEMP_ARRAY :=
  67.     (50.0, 55.0, 60.0, 65.0, 70.0, 75.0, 80.0, 85.0, 90.0, 95.0,
  68.      100.0, 110.0, 120.0, 130.0, 140.0, 150.0, 145.0, 140.0, 120.0,
  69.      100.0, 80.0, 70.0, 60.0);
  70.  
  71.   Water_Temp : constant TEMP_ARRAY :=
  72.     (32.0, 32.0, 34.0, 37.0, 38.0, 40.0, 42.0, 50.0, 60.0, 65.0,
  73.      70.0, 75.0, 80.0, 82.0, 83.0, 84.0, 80.0, 78.0, 82.0, 70.0,
  74.      60.0, 50.0, 40.0, 35.0, 30.0, 25.0, 20.0, 15.0, 10.0, 17.0,
  75.      20.0, 22.0, 27.0, 30.0, 31.0);
  76.  
  77.   Wind : constant SPEED_ARRAY :=
  78.     (5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 25.0, 22.0, 20.0, 17.0, 14.0,
  79.      12.0, 9.0, 7.0, 4.0, 2.0, 1.0, 0.0, 0.0, 1.0, 3.0);
  80.  
  81.   Red_Light_Status : constant FLAG_ARRAY :=
  82.     (OFF, OFF, OFF, ON, ON, OFF, OFF, OFF, ON, OFF, OFF, OFF, OFF,
  83.      ON, ON, OFF, OFF, OFF, OFF, OFF, OFF, OFF, ON, OFF, OFF, OFF);
  84.  
  85.   Yellow_Light_Status : constant FLAG_ARRAY :=
  86.     (OFF, ON, OFF, OFF, ON, OFF, OFF, OFF, OFF, ON, OFF, OFF, OFF,
  87.      ON, OFF, OFF, OFF, ON, OFF, OFF, ON, OFF);
  88.  
  89.   -- .............................................
  90.   -- .                                           .
  91.   -- .  Buoy_Sensor_Interface.Air_Temperature    .  BODY
  92.   -- .                                           .
  93.   -- .............................................
  94.   function Air_Temperature (ID : in BUOY_ID) return TEMPERATURE is
  95.   begin
  96.     return Air_Temp(Air_Temp_Index(ID));
  97.   end Air_Temperature;
  98.  
  99.   -- .............................................
  100.   -- .                                           .
  101.   -- .  Buoy_Sensor_Interface.Water_Temperature  .  BODY
  102.   -- .                                           .
  103.   -- .............................................
  104.   function Water_Temperature (ID : in BUOY_ID) return TEMPERATURE is
  105.   begin
  106.     return Water_Temp(Water_Temp_Index(ID));
  107.   end Water_Temperature;
  108.  
  109.   -- .............................................
  110.   -- .                                           .
  111.   -- .  Buoy_Sensor_Interface.Wind_Speed         .  BODY
  112.   -- .                                           .
  113.   -- .............................................
  114.   function Wind_Speed (ID : in BUOY_ID) return SPEED is
  115.   begin
  116.     return Wind(Wind_Speed_Index(ID));
  117.   end Wind_Speed;
  118.  
  119.   -- .............................................
  120.   -- .                                           .
  121.   -- .  Buoy_Sensor_Interface.Global_Position    .  BODY
  122.   -- .                                           .
  123.   -- .............................................
  124.   function Global_Position (ID : in BUOY_ID) return LOCATION is
  125.   begin
  126.     return My_Position(ID);
  127.   end Global_Position;
  128.  
  129.   -- .............................................
  130.   -- .                                           .
  131.   -- .  Buoy_Sensor_Interface.Red_Light          .  BODY
  132.   -- .                                           .
  133.   -- .............................................
  134.   function Red_Light (ID : in BUOY_ID) return OFF_ON is
  135.   begin
  136.     return Red_Light_Status(Red_Index(ID));
  137.   end Red_Light;
  138.  
  139.   -- .............................................
  140.   -- .                                           .
  141.   -- .  Buoy_Sensor_Interface.Yellow_Light       .  BODY
  142.   -- .                                           .
  143.   -- .............................................
  144.   function Yellow_Light (ID : in BUOY_ID) return OFF_ON is
  145.   begin
  146.     return Yellow_Light_Status(Yellow_Index(ID));
  147.   end Yellow_Light;
  148.  
  149.   -- .............................................
  150.   -- .                                           .
  151.   -- .  Buoy_Sensor_Interface.Update             .  BODY
  152.   -- .                                           .
  153.   -- .............................................
  154.   procedure Update (ID : in BUOY_ID) is
  155.   begin
  156.     Air_Temp_Index(ID) := Air_Temp_Index(ID) + 1;
  157.     if Air_Temp_Index(ID) > Air_Temp'LAST then
  158.       Air_Temp_Index(ID) := 0;
  159.     end if;
  160.     Water_Temp_Index(ID) := Water_Temp_Index(ID) + 1;
  161.     if Water_Temp_Index(ID) > Water_Temp'LAST then
  162.       Water_Temp_Index(ID) := 0;
  163.     end if;
  164.     Wind_Speed_Index(ID) := Wind_Speed_Index(ID) + 1;
  165.     if Wind_Speed_Index(ID) > Wind'LAST then
  166.       Wind_Speed_Index(ID) := 0;
  167.     end if;
  168.     Red_Index(ID) := Red_Index(ID) + 1;
  169.     if Red_Index(ID) > Red_Light_Status'LAST then
  170.       Red_Index(ID) := 0;
  171.     end if;
  172.     Yellow_Index(ID) := Yellow_Index(ID) + 1;
  173.     if Yellow_Index(ID) > Yellow_Light_Status'LAST then
  174.       Yellow_Index(ID) := 0;
  175.     end if;
  176.   end Update;
  177.  
  178. end Buoy_Sensor_Interface;
  179.